<?php

    //Sub Table Class define
    include_once("ClassSub.php");

class UnitClass
{
	var $Bedrooms;
	var $Baths;
	var $RentIncome;
	var $LivingArea;
    var $TotalRooms;
	
	var $ID;
	var $idParent;
	
	function AddItemFromXML($XmlArray)
	{
		$Array = $XmlArray->children();
			
	 	$this->Bedrooms = $Array[0];
	 	$this->Baths = new UnitBathsClass;
		$this->Baths->AddItemFromXML($Array[1]);
	 	$this->RentIncome = new CurrencyFormatClass;
		$this->RentIncome->AddItemFromXML($Array[2]);
	 	$this->LivingArea = new LivingAreaClass;
		$this->LivingArea->AddItemFromXML($Array[3]);
		$Rooms = $Array[4]->children();
		$this->TotalRooms = $Rooms[0];
	}
	
	function InsertSQL( $InputID )
	{
		$this->Baths->InsertSQL();		
		$this->RentIncome->InsertSQL();		
		$this->LivingArea->InsertSQL();		

		$strSqlCommand = "INSERT INTO Unit( MultiFamily_idMultiFamily, Bedrooms, Baths_idBaths, ";
		$strSqlCommand .="RentIncome, LivingArea_idLivingArea, TotalRooms) ";
		$strSqlCommand .= "VALUES( '".$InputID."', ";
		$strSqlCommand .= "'".$this->Bedrooms."', ";
		$strSqlCommand .= "'".$this->Baths->ID."', ";
		$strSqlCommand .= "'".$this->RentIncome->ID."', ";
		$strSqlCommand .= "'".$this->LivingArea->ID."', ";
		$strSqlCommand .= "'".$this->TotalRooms."') ";
				
		if(!mysql_query($strSqlCommand))
		{
			echo $strSqlCommand."<br/>";
		}
		$this->ID = mysql_insert_id();		
	}
	
	function ModifySQL( $InputID )
	{
/*		$this->ID = $InputID;

		$strSqlCommand = "SELECT * FROM MLSInformation ";
		$strSqlCommand .= " WHERE idMLSInformation = '".$this->ID."' ";
		$result = mysql_query($strSqlCommand);
		$rowListingData = @mysql_fetch_array($result);

		$strSqlCommand =  "UPDATE MLSInformation SET ";
		$strSqlCommand .= "ListingStatus='"		.$this->ListingStatus		."', ";
		$strSqlCommand .= "ListingArea='"		.$this->ListingArea			."', ";
		$strSqlCommand .= "StatusChangeDate='"	.$this->StatusChangeDate	."', ";
		$strSqlCommand .= "DaysOnMarket='"		.$this->DaysOnMarket		."', ";
		$strSqlCommand .= "ListingServiceName='".$this->ListingServiceName	."' ";
		$strSqlCommand .= "WHERE idMLSInformation = ".$this->ID;
		mysql_query($strSqlCommand);

		$this->OriginalListPrice->ModifySQL( $rowListing["OriginalListPrice"]);		
		*/	
	}	
}

?>